Skip to content

fix(graph): reject tag assignments that exceed the maximum - #3910

Open
thelastbackspace wants to merge 1 commit into
opencloud-eu:mainfrom
thelastbackspace:fix/3893-tags-max
Open

thelastbackspace wants to merge 1 commit into
opencloud-eu:mainfrom
thelastbackspace:fix/3893-tags-max

Conversation

@thelastbackspace

Copy link
Copy Markdown

Description

AssignTags passed the requested tags straight to reva's tags.Add. That stops at 100 tags per resource without saying so and only returns whether at least one tag got added, so a request that only partly fit stored some of the tags and still returned 200.

This collects the distinct new tags first (split on ,, empties and already existing tags skipped), and if they don't all fit the whole request is rejected with the existing 400 "no new tags in createtagsrequest or maximum reached", so nothing is stored partially. The TagsAdded event now only carries the tags that were actually added instead of the raw request list (which also included duplicates and tags the resource already had).

Related Issue

Motivation and Context

Clients had no way to notice that tags were dropped, and event consumers saw tags that were never stored.

How Has This Been Tested?

  • Added services/graph/pkg/service/v0/tags_test.go:
    • 95 existing + 10 new tags -> 400, SetArbitraryMetadata not called, no event (fails on main: the partial write goes through)
    • 95 existing + 5 new -> 200
    • existing a,b, request a,c,c,d -> event has c,d (main publishes a,c,c,d)
  • go test ./services/graph/... passes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

AssignTags passed the requested tags to reva's tags.Add, which stops at
the maximum of 100 tags per resource without reporting it and only says
whether at least one tag was added. So a request that didn't fully fit
stored part of the tags and still returned 200, and the TagsAdded event
listed every requested tag, including the dropped and already existing
ones.

Collect the distinct new tags first, reject the whole request with 400
unless all of them fit, and only publish the tags that were added.

Fixes opencloud-eu#3893
@codacy-production

codacy-production Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 20 complexity

Metric Results
Complexity 20

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.06% coverage variation

Metric Results
Coverage variation ✅ +0.06% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2eb513b) 93435 26771 28.65%
Head commit (679a704) 93450 (+15) 26832 (+61) 28.71% (+0.06%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3910) 17 17 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pbleser-oc pbleser-oc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up, and for the tests.

The fix does what the issue describes: the whole request is rejected when the new tags don't all fit, and the event only carries the tags that were actually added.

Looks good to me. I've started the CI run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graph: assigning tags beyond the maximum silently drops some of them

2 participants